package main

import (
	"alisms/route"

	"github.com/kataras/iris"
	"github.com/kataras/iris/context"
	"github.com/kataras/iris/middleware/logger"
)

func main() {
	app := iris.New()
	app.RegisterView(iris.HTML("./views", ".html").Delims("{{{", "}}}").Reload(true))
	clog := logger.New(logger.Config{
		Status: true,
		IP:     true,
		Method: true,
		Path:   true,
	})
	app.Use(clog)
	app.Get("/", func(ctx context.Context) {
		ctx.View("index.html")
	})

	// app.Use(func(ctx context.Context) {
	// 	ctx.Application().Log("Begin request for path: %s", ctx.Path())
	// 	ctx.Next()
	// })
	// app.OnError(iris.StatusNotFound, func(ctx context.Context) {
	// 	ctx.HTML(iris.StatusNotFound, "<h2> 404 not found!</h2>")
	// })
	app.StaticWeb("/statics", "./statics/")
	app.Post("/upfile", route.Msg.Upfile)
	app.Post("/sendmsg", route.Msg.Sendmsg)
	app.Post("/getall", route.Templ.Getall)
	app.Post("/save", route.Templ.Save)
	app.Post("/del", route.Templ.Del)
	
	app.Run(iris.Addr(":8090"))
}
